cmake_minimum_required(VERSION 3.0)

SET(PRODUCT_NAME MainWindow)

SET(PRODUCT_HEADER_FILES
    mainwindow.h
	MoveableWidget.h
	AutoHideMessageBox.h
	GIFPlayer.h
	TableHeadViewWithCheckBox.h
	TreeWidget.h
	Toast.h
	DarkStyleUI/DarkStyle.h
	DarkStyleUI/framelesswindow/windowdragger.h
	DarkStyleUI/framelesswindow/framelesswindow.h
)

SET(PRODUCT_UI_FILES
    mainwindow.ui
	MoveableWidget.ui
	AutoHideMessageBox.ui
	Toast.ui
	DarkStyleUI/framelesswindow/framelesswindow.ui
)

SET(PRODUCT_FILES
    main.cpp
    mainwindow.cpp
	MoveableWidget.cpp
	AutoHideMessageBox.cpp
	GIFPlayer.cpp
	TableHeadViewWithCheckBox.cpp
	TreeWidget.cpp
	Toast.cpp
	DarkStyleUI/DarkStyle.cpp
	DarkStyleUI/framelesswindow/windowdragger.cpp
	DarkStyleUI/framelesswindow/framelesswindow.cpp
    ${PRODUCT_HEADER_FILES}
)

SET(PRODUCT_DATA_FILES
)

QT5_WRAP_UI(UI_FILES ${PRODUCT_UI_FILES}) 
QT5_WRAP_CPP(MOC_FILES ${PRODUCT_HEADER_FILES})

SET(PRODUCT_FILES ${PRODUCT_FILES} ${UI_FILES} ${MOC_FILES})
IF(WIN32)
    #SET(PRODUCT_FILES ${PRODUCT_FILES} my.rc)
ENDIF(WIN32)

QT5_ADD_RESOURCES(RES_FILES ui/main.qrc DarkStyleUI/framelesswindow.qrc DarkStyleUI/darkstyle.qrc)

SET(PRODUCT_FILES ${PRODUCT_FILES} ${RES_FILES})

#文件夹筛选器文件分类
SOURCE_GROUP("auto generated files" FILES ${UI_FILES} ${MOC_FILES} ${RES_FILES})
SOURCE_GROUP("ui files" FILES ${PRODUCT_UI_FILES})

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

#Qt库目录
LINK_DIRECTORIES(${Qt5Widgets_DIR}/../..)
#MESSAGE(${Qt5Widgets_DIR}/../..)

SET(WITH_CONSOLE 1)
IF(${WITH_CONSOLE})
    ADD_EXECUTABLE(${PRODUCT_NAME} ${PRODUCT_FILES})
ELSE(${WITH_CONSOLE})
    ADD_EXECUTABLE(${PRODUCT_NAME} WIN32 ${PRODUCT_FILES})
ENDIF(${WITH_CONSOLE})

SET_TARGET_PROPERTIES(${PRODUCT_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")

QT5_USE_MODULES(${PRODUCT_NAME} Gui Core Widgets Network OpenGL)
# 注意加载网页需要WebEngineWidgets组件，这个在Qt5.6之后替换了之前的Webkit组件。
# 特别注意在安装Qt的时候，要勾选Qt WebEngine，否则不会安装此模块
# Qt版本小于5.6时，需要注释下一行
#QT5_USE_MODULES(${PRODUCT_NAME} WebEngineWidgets)

TARGET_LINK_LIBRARIES(${PRODUCT_NAME}
    ${OPENGL_LIBRARIES} ${THIRD_PARTY_LIBRARIES} ${EXTERNAL_LIBRARIES}
)

SET_TARGET_PROPERTIES(${PRODUCT_NAME} PROPERTIES 
    ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/lib"
    ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/lib"
    LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/lib"
    LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/lib"
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/bin"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin")

SETUP_VS_DEBUGGER_PARAMS(${PRODUCT_NAME} ${SOLUTION_FOLDER_NAME})

INSTALL(TARGETS ${PRODUCT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
INSTALL(FILES ${PRODUCT_DATA_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/data)